window.gdata = {
    musicList: [],
    month: $('#month').val() || 5,
    openid: $('#openid').val() || 'o3jaq1YxJB8luCCUXzJpM7tdC8Wk',
    timeStr: new Date().getTime(),
    last_music_no: $('#last_music_no').val() || '10504',
    pregnancy_days: $('#pregnancy_days').val() || '55',
    pregnancy_weektps: $('#pregnancy_weektps').val() || '0周+5天',
    pregnancy_childbirth_date: $('#pregnancy_childbirth_date').val() || '2018-12-12',
    pregnancy_remain_days: $('#pregnancy_remain_days').val() || '99',
    host: 'http://pbmama.api01.net',
    appid: $('#appid').val() || '1',
    timestamp: $('#timestamp').val() || '2',
    nonceStr: $('#nonceStr').val() || '3',
    signature: $('#signature').val() || '4',
}

function ajax(options) {
    $.ajax({
        url: gdata.host + options.url,
        type: options.type || "GET",
        data: options.data || {},
        success: function (res) {
            if (options.success) {
                options.success(res)
            }
        },
        error: function (res) {
            console.log(res)
            if (options.error) {
                options.error(res)
            }
        }
    })
}

Date.prototype.format = function (format) {
    var o = {
        'M+': this.getMonth() + 1, // month
        'd+': this.getDate(),    // day
        'h+': this.getHours(),   // hour
        'm+': this.getMinutes(), // minute
        's+': this.getSeconds(), // second
        'q+': Math.floor((this.getMonth() + 3) / 3),  // quarter
        'S': this.getMilliseconds() // millisecond
    }
    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1,
            (this.getFullYear() + '').substr(4 - RegExp.$1.length))
    }
    for (var k in o) {
        if (new RegExp('(' + k + ')').test(format)) {
            format = format.replace(RegExp.$1,
                RegExp.$1.length == 1 ? o[k]
                    : ('00' + o[k]).substr(('' + o[k]).length))
        }
    }
    return format
}


